From: Richard M. Stallman Date: Sun, 6 Jun 1993 03:27:43 +0000 (+0000) Subject: (x_new_font): Don't give up right away if XListFontsWithInfo X-Git-Tag: archive/raspbian/1%29.2+1-2+rpi1^2~5^2~95549 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=5835f8608107136eddace7252219857c920a8c96;p=emacs.git (x_new_font): Don't give up right away if XListFontsWithInfo finds no fonts--try XLoadQueryFont anyway. --- diff --git a/src/xterm.c b/src/xterm.c index 4c1c79bf444..fc1b995e1a3 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -3916,30 +3916,29 @@ x_new_font (f, fontname) font_names = (char **) XListFontsWithInfo (x_current_display, fontname, 1024, &n_matching_fonts, &font_info); - - /* If the server couldn't find any fonts whose named matched fontname, - return an error code. */ - if (n_matching_fonts == 0) - return Qnil; + /* Don't just give up if n_matching_fonts is 0. + Apparently there's a bug on Suns: XListFontsWithInfo can + fail to find a font, but XLoadQueryFont may still find it. */ /* See if we've already loaded a matching font. */ - { - int i, j; + already_loaded = -1; + if (n_matching_fonts != 0) + { + int i, j; - already_loaded = 0; - for (i = 0; i < n_fonts; i++) - for (j = 0; j < n_matching_fonts; j++) - if (x_font_table[i]->fid == font_info[j].fid) - { - already_loaded = i; - fontname = font_names[j]; - goto found_font; - } - } + for (i = 0; i < n_fonts; i++) + for (j = 0; j < n_matching_fonts; j++) + if (x_font_table[i]->fid == font_info[j].fid) + { + already_loaded = i; + fontname = font_names[j]; + goto found_font; + } + } found_font: /* If we have, just return it from the table. */ - if (already_loaded) + if (already_loaded > 0) f->display.x->font = x_font_table[already_loaded]; /* Otherwise, load the font and add it to the table. */ @@ -3958,14 +3957,18 @@ x_new_font (f, fontname) i = 0; #endif - if (i >= n_matching_fonts) - return Qt; - else + /* See comment above. */ + if (n_matching_fonts != 0) fontname = font_names[i]; font = (XFontStruct *) XLoadQueryFont (x_current_display, fontname); if (! font) - return Qnil; + { + /* Free the information from XListFontsWithInfo. */ + if (n_matching_fonts) + XFreeFontInfo (font_names, font_info, n_matching_fonts); + return Qnil; + } /* Do we need to create the table? */ if (x_font_table_size == 0)